﻿@using ControleRepresentante.Logic.Models
@using Telerik.Web.Mvc.UI
<!DOCTYPE html>
<html>
<head>
    <title>Controle Representante</title>
    
    <link rel="Shortcut Icon" href="@Url.Content("~/favicon.ico")" />

    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/ui-lightness/jquery-ui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/token-input-facebook.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/token-input.css")" rel="stylesheet" type="text/css" />

    @Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.vista.css"))
</head>

<body>
    @{ UserInfo userInfo = Session["UserInfo"] as UserInfo; }

    <div style="width:100%; background-color:#003344">
        <span style="color:White;font-size:xx-large; margin-left:95px;">@Session["RepresentanteNome"]</span>
        @if (userInfo != null)
        {
            <br />
            <span style="color:White;margin-left:95px;">Usuario: @userInfo.Username</span>
        }
    </div>
    <div class="page">
        <div id="header">
            <div id="menucontainer">
                @{ Html.Telerik().Menu()
                        .Name("Menu")
                        .Items(menu =>
                        {
                            menu.Add()
                                .Text("Home")
                                .ImageUrl("~/Content/home.png")
                                .Action("Index", "Home");
                            if (userInfo != null && userInfo.IsAdmin)
                            {
                                menu.Add()
                                    .Text("Representantes")
                                    .ImageUrl("~/Content/representante.png")
                                    .Action("Index", "Representante");
                            }
                            else if (Session["RepresentanteId"] != null)
                            {
                                if (userInfo.HasPermission(Area.Atributos, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Atributos")
                                        .ImageUrl("~/Content/attributes.png")
                                        .Action("Index", "Attribute");
                                }
                                if (userInfo.HasPermission(Area.Vendedores, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Vendedores")
                                        .ImageUrl("~/Content/vendedor.png")
                                        .Action("Index", "Vendedor");
                                }
                                if (userInfo.HasPermission(Area.Clientes, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Clientes")
                                        .ImageUrl("~/Content/cliente.png")
                                        .Action("Index", "Cliente");
                                }
                                if (userInfo.HasPermission(Area.Fabricas, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Fábricas")
                                        .ImageUrl("~/Content/fabrica.png")
                                        .Action("Index", "Fabrica");
                                }
                                if (userInfo.HasPermission(Area.Transportadoras, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Transportadoras")
                                        .ImageUrl("~/Content/transportadora.png")
                                        .Action("Index", "Transportadora");
                                }
                                if (userInfo.HasPermission(Area.Pedidos, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Pedidos")
                                        .ImageUrl("~/Content/pedido.png")
                                        .Action("Index", "Pedido");
                                }
                                if (userInfo.HasPermission(Area.Produto, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Produtos")
                                        .ImageUrl("~/Content/produto.png")
                                        .Action("Index", "Produto");                                    
                                }
                                if (userInfo.HasPermission(Area.RelatorioVisita, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Relatório de Visita")
                                        .ImageUrl("~/Content/relatorio.png")
                                        .Action("Index", "RelatorioVisita");
                                }
                                if (userInfo.HasPermission(Area.Usuarios, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Usuários")
                                        .ImageUrl("~/Content/users.png")
                                        .Action("Index", "Usuario");
                                }
                                if (userInfo.HasPermission(Area.Configuracoes, Operacao.View))
                                {
                                    menu.Add()
                                        .Text("Configurações")
                                        .ImageUrl("~/Content/configuracoes.png")
                                        .Action("Details", "Configuracoes");
                                }
                                if (userInfo.HasPermission(Area.Sync, Operacao.Synchronize))
                                {
                                    menu.Add()
                                        .Text("Sincronizar")
                                        .ImageUrl("~/Content/sync.png")
                                        .Action("Index", "Sync");
                                }
                                if (userInfo.HasPermission(Area.Pedidos, Operacao.Compare))
                                {
                                    menu.Add()
                                        .Text("Comparativo")
                                        .ImageUrl("~/Content/statistics.png")
                                        .Action("Index", "Compare");
                                }
                            }
                            if (userInfo == null)
                            {
                                menu.Add()
                                    .Text("Login")
                                    .ImageUrl("~/Content/login.png")
                                    .Action("Index", "Login");
                            }
                            else
                            {
                                menu.Add()
                                    .Text("Alterar Meus Dados")
                                    .ImageUrl("~/Content/myinfo.png")
                                    .Action("Details", "MyInfo");

                                menu.Add()
                                    .Text("Logout")
                                    .ImageUrl("~/Content/login.png")
                                    .Action("Logout", "Login");
                            }
                        })
                        .Render();}
            </div>
        </div>

        <div id="main">
            @RenderBody()
            <div id="footer"></div>
        </div>
    </div>

    @Html.Telerik().ScriptRegistrar().Globalization(true)

    <script src="@Url.Content("~/Scripts/jquery.tokeninput.js")" type="text/javascript"></script>

</body>
</html>
